package annotation

import (
	"fmt"

	"github.com/zfd81/rooster/util"
)

func Parser(query string) (string, Annotations) {
	annotations := Annotations{}
	for k, v := range Type_name {
		open := fmt.Sprintf("@%s(", v)
		typAnnotation := []Annotation{}
		query, _ = util.ReplaceBetween(query, open, ")", func(index int, start int, end int, content string) (string, error) {
			typAnnotation = append(typAnnotation, &BaseAnnotation{
				atype: k,
				value: content,
			})
			return "", nil
		})
		annotations[k] = typAnnotation
	}
	return query, annotations
}
